<template>
	<view class="content">
		<headerbox :cixitype="cixi"></headerbox>
		<view class="pages">
			<swiper class="banner" :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000" circular="true">
				<swiper-item v-for="(item,index) in setting.banners" :key="index">
					<view class="swiper-item">
						<image :src="baseURLs + item.path" mode=""></image>
					</view>
				</swiper-item>
			</swiper>
			<view class="marquee">
				<view>
					<image src="../../static/timg/lingdang.png" mode=""></image>
					<text v-if="gonggaolist.length > 0">{{gonggaolist[0].content}}</text>
				</view>
			</view>
			<view class="card">
				<view class="card-body">
					<view class="d-flex">
						<view class="flexd">
							<view class="left">
								<image class="avatar" src="" mode=""></image>
								<view class="info">
									<h4>{{userinfo.name}}</h4>
									<view class="font-weight-normal">RMB</view>
									<view class="contract_due_home">
										<view class="level">等级:</view>
										<view class="badge">{{userinfo.level_name}}</view>
									</view>
								</view>
							</view>
						</view>
						<view class="right_package">
							<view class="inner_right_top">
								<text>您受MY保护</text>
								<image src="../../static/logo.png" mode=""></image>
							</view>
							<view class="btn">立即受保</view>
							<view class="package_status" v-if="userinfos.is_claim != null">
								<image src="../../static/timg/cuowu.png" mode=""></image>
								<view>未受保护</view>
							</view>
						</view>
					</view>
					<view class="bottom_profile_package">
						<view>保险合约</view>
						<image src="../../static/timg/right.png" mode=""></image>
					</view>
				</view>
			</view>
			<view class="card">
				<view class="d-flex" style="padding: 40rpx;">
					<view class="ditem" @click="goSwichPage('/pages/user/recharge')">
						<image src="../../static/timg/qianbao.png" mode=""></image>
						<text>充值</text>
					</view>
					<view class="ditem" @click="goSwichPage('/pages/contract/contract')">
						<image src="../../static/timg/qianbao.png" mode=""></image>
						<text>套餐</text>
					</view>
					<view class="ditem" @click="goSwichPage('/pages/user/claim')">
						<image src="../../static/timg/suopei.png" mode=""></image>
						<text>索赔</text>
					</view>
					<view class="ditem" @click="gokefu()">
						<image src="../../static/timg/kefu.png" mode=""></image>
						<text>联系我们</text>
					</view>
				</view>
			</view>
			<view class="card">
				<view class="card-body">
					<view class="display_space" @click="goSwichPage('/pages/user/assets')">
						<view class="label_title">钱包</view>
						<image src="../../static/timg/right1.png" mode=""></image>
					</view>
					<view class="display_space1">
						<view class="dsleft">保险积分</view>
						<view class="dsright">RMB {{userinfo.fs_money||0}}</view>
					</view>
					<view class="display_space1">
						<view class="dsleft">MY积分</view>
						<view class="dsright">{{userinfo.money||0}}</view>
					</view>
				</view>
			</view>
			<view class="card">
				<view class="card-body">
					<view class="display_space">
						<view class="label_title" style="color: #c5993a;">保费</view>
					</view>
					 <uni-calendar 
					    :insert="true"
					    :lunar="true" 
					    :start-date="'2019-3-2'"
					    :end-date="'2039-5-20'"
					    @change="change"
					     />
				</view>
			</view>
		</view>
		<view class="footer-bar" :class="cixi ? '':'footer-bar-detached'">
			<view class="fbitem" @click="goSwichPage('/pages/index/index')">
				<view class="image">
					<image src="../../static/timg/shouye.png" mode=""></image>
				</view>
				<view class="text">首页</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/contract/contract')">
				<view class="image">
					<image src="../../static/timg/heyue.png" mode=""></image>
				</view>
				<view class="text">合约</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/assets')">
				<view class="image">
					<image src="../../static/timg/zichan.png" mode=""></image>
				</view>
				<view class="text">资产</view>
			</view>
			<view class="fbitem" @click="goSwichPage('/pages/user/claim')">
				<view class="image">
					<image src="../../static/timg/suopei.png" mode=""></image>
				</view>
				<view class="text">索赔</view>
			</view>
		</view>
	</view>
</template>

<script>
	import headerbox from '@/pages/header.vue'
	import { getuserinfo,message,sysconfig } from '../../api/api.js'
	import { baseURL } from '@/api/http.js'
	export default {
		components:{
			headerbox
		},
		data() {
			return {
				cixi:false,
				
				baseURLs: baseURL,
				setting:[],
				gonggaolist:[],
				userinfo:[],
				userinfos:[]
			}
		},
		onLoad() {
			this.getsysconfig()
			if(uni.getStorageSync('token')){
				this.getuserinfo()
				this.getgonggao()
			}
		},
		onPageScroll(e) {
			if(e.scrollTop > 0){
				this.cixi = true
			}else{
				this.cixi = false
			}
		},
		methods: {
			change(e){
				console.log(e)
			},
			goSwichPage(page){
				uni.navigateTo({
					url:page
				})
			},
			getuserinfo(){
				let datas = {
					type:1
				}
				getuserinfo(datas).then(res => {
					if(res.data.status.errorCode == 0){
						uni.setStorageSync('userinfo', JSON.stringify(res.data.data.member))
						this.userinfo = res.data.data.member
						this.userinfos = res.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getgonggao(){
				let datas = {
					page:1,
					type:1
				}
				message(datas).then(res => {
					if(res.data.status.errorCode == 0){
						this.gonggaolist = res.data.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			getsysconfig(){
				let datas = {
					type:1
				}
				sysconfig(datas).then(res => {
					if(res.data.status.errorCode == 0){
						this.setting = res.data.data
					}
				}).catch(err => {
					console.log(err)
				})
			},
			gokefu(){
				window.open(this.setting.service_link)
			}
		}
	}
</script>

<style scoped lang="scss">
	*{
		box-sizing: border-box;
	}
	.content{
		width: 100%;
		min-height: 100vh;
		background-color: #f1f1f7;
		color: #747474 !important;
	}
	.pages{
		padding-top: calc(calc(110rpx + 60rpx) + env(safe-area-inset-top));
		padding-bottom: calc(120rpx + env(safe-area-inset-bottom));
	}
	.banner{
		height: 374rpx;
		margin-bottom: 20rpx;
		
		image{
			width: 100%;
			height: 374rpx;
		}
	}
	.marquee{
		white-space: nowrap;
		overflow: hidden;
		position: relative;
		width: 96%;
		background: #fff;
		display: flex;
		margin: 0 auto;
		margin-bottom: 20rpx;
		padding: 12rpx;
		border-radius: 20rpx;
		color: #000;
		
		&>view{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			padding-left: 100%;
			animation: marquee 10s linear infinite;
		}
		
		image{
			width: 38rpx;
			height: 36rpx;
		}
		text{
			color: #000;
			font-size: 28rpx;
			line-height: 48rpx;
		}
	}
	@keyframes marquee {
		0% {
		    transform: translate(0, 0);
		}
		
		100% {
		    transform: translate(-100%, 0);
		}
	}
	
	.card{
		width: 94%;
		margin: 0 auto;
		border-radius: 20rpx;
		position: relative;
		display: flex;
		flex-direction: column;
		word-wrap: break-word;
		margin-bottom: 30rpx;
		background-color: #fff;
		box-shadow: rgba(0, 0, 0, .35) 0px 30px 60px -30px, rgba(0, 0, 0, .35) 0px -2px 6px 0px inset;
	}
	.card-body{
		z-index: 3;
		flex: 1 1 auto;
		padding: 40rpx;
	}
	.d-flex{
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.flexd{
		display: flex;
		flex-direction: column;
	}
	.left{
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}
	.avatar{
		width: 120rpx;
		height: 120rpx;
		margin-right: 20rpx;
	}
	h4{
		color: #1b1b1b;
		font-size: 36rpx;
		line-height: 46rpx;
		font-weight: 700;
		margin-bottom: 10rpx;
	}
	.font-weight-normal{
		font-size: 32rpx;
		color: #2a2a2a;
		line-height: 48rpx;
	}
	.contract_due_home{
		font-size: 32rpx;
		color: #2a2a2a;
		display: flex;
		justify-content: flex-start;
		align-items: center;
	}
	.level{
		font-size: 22rpx;
	}
	.badge{
		font-size: 26rpx;
		background-color: rgba(220, 53, 69,1);
		padding: 9rpx 17rpx;
		color: #fff;
		border-radius: 10rpx;
	}
	.right_package{
		width: 40%;
		text-align: right;
	}
	.inner_right_top{
		display: flex;
		align-items: center;
		padding-bottom: 32rpx;
		justify-content: flex-end;
		
		text{
			font-size: 20rpx;
			line-height: 1.2;
			padding-right: 12rpx;
			padding-left: 20rpx;
		}
		image{
			width: 100rpx;
			height: 80rpx;
		}
	}
	.btn{
		width: 100%;
		background-color: #ffc107;
		font-size: 22rpx;
		line-height: 1.5;
		padding: 16rpx 26rpx;
		font-weight: 700;
		border-radius: 24rpx;
		box-shadow: 0 10rpx 28rpx 0 rgba(0, 0, 0, 0.1);
		color: #FFF;
		text-align: center;
	}
	.package_status{
		display: flex;
		justify-content: flex-end;
		align-items: center;
		height: 52rpx;
		
		image{
			width: 24rpx;
			height: 24rpx;
			margin-right: 4rpx;
		}
		view{
			color: #f00;
			font-size: 24rpx;
		}
	}
	.bottom_profile_package{
		margin: 30rpx -32rpx 0 -40rpx;
		padding: 28rpx 28px 0;
		border-top: solid 2rpx #ebebeb;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
		view{
			color: #c5993a;
			font-size: 26rpx;
		}
		image{
			width: 28rpx;
			height: 28rpx;
		}
	}
	.ditem{
		width: 160rpx;
		height: 160rpx;
		padding: 20rpx;
		border-radius: 50%;
		text-align: center;
		color: #818181;
		font-weight: bold;
		
		image{
			width: 28rpx;
			height: 28rpx;
		}
		text{
			color: #797979;
			padding-top: 12rpx;
			font-size: 22rpx;
			font-weight: bold;
			text-align: center;
			display: block;
			line-height: 48rpx;
		}
	}
	.display_space{
		color: #2a2a2a;
		font-size: 26rpx;
		font-weight: bold;
		margin-bottom: 4rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 48rpx;
		
		image{
			width: 32rpx;
			height: 32rpx;
		}
	}
	.label_title{
		color: #2a2a2a;
		font-size: 28rpx;
		font-weight: bold;
	}
	.display_space1{
		color: #2a2a2a;
		font-size: 26rpx;
		font-weight: bold;
		display: flex;
		align-items: center;
		justify-content: space-between;
		line-height: 52rpx;
		
		.dsleft{
			color: #c5993a;
			font-weight: normal;
		}
	}
	/deep/ .uni-calendar-item__weeks-box-item{
		width: 90rpx;
	}
	
	.footer-bar{
		background-color: rgba(255, 255, 255, 0.95);
		padding: 0px 20rpx;
		position: fixed;
		bottom: 0px;
		left: 0px;
		right: 0px;
		z-index: 98;
		backdrop-filter: blur(20rpx);
		display: flex;
		text-align: center;
		transition: all 250ms ease;
		height: calc(120rpx + env(safe-area-inset-bottom));
		box-shadow: 0 -10rpx 10rpx 0 rgba(0, 0, 0, 0.04);
	}
	.footer-bar.footer-bar-detached{
		border-radius: 40rpx;
		left: 20rpx !important;
		right: 20rpx !important;
		bottom: 30rpx !important;
		box-shadow: 0 0px 30rpx 0 rgba(0, 0, 0, 0.1) !important;
		height: 120rpx !important;
	}
	.fbitem{
		color: #818181;
		position: relative;
		flex: 1 1 auto;
		padding-top: 24rpx;
		
		.image{
			height: 48rpx;
			margin-top: -4rpx;
			
			image{
				width: 36rpx;
				height: 36rpx;
			}
		}
		.text{
			height: 48rpx;
			margin-top: -6rpx;
			font-size: 24rpx;
			opacity: 0.7;
			color: #818181;
		}
	}
</style>
